package me.flyray.crm.core.modules.netty.handlers;

import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.timeout.IdleState;
import io.netty.handler.timeout.IdleStateEvent;
import io.netty.handler.timeout.IdleStateHandler;

public class StateHandler extends IdleStateHandler{

	public StateHandler(int readerIdleTimeSeconds, int writerIdleTimeSeconds, int allIdleTimeSeconds) {
		super(readerIdleTimeSeconds, writerIdleTimeSeconds, allIdleTimeSeconds);
	}
	@Override
    protected void channelIdle(ChannelHandlerContext ctx, IdleStateEvent evt) {
		IdleState state = ((IdleStateEvent) evt).state();
		if (state == IdleState.READER_IDLE) {
			 System.out.println("16" + "秒内未读到数据，关闭连接");
		     NettyChannelMap.remove(ctx.channel());
		}
    }
}
